package com.huowei.htzy.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by huowei on 2016/10/10.
 */

public class SharedUtils {
    private static SharedUtils utils;
    private static SharedPreferences sp;

    public static SharedUtils getInstance(Context context){
        if (utils == null) {
            utils = new SharedUtils();
        }
        sp = context.getSharedPreferences("HTZY", Context.MODE_PRIVATE);
        return utils;
    }
    public void putString(String key,String value){
        sp.edit().putString(key,value).commit();
    }
    public String getString(String key){
        return sp.getString(key, "");
    }
    public void putBoolean(String key,boolean flag){
        sp.edit().putBoolean(key,flag).commit();
    }
    public boolean getBoolean(String key){
        return sp.getBoolean(key, false);
    }
    public void putInt(String key,int count){
        sp.edit().putInt(key,count).commit();
    }
    public int putInt(String key){
        return sp.getInt(key, 0);
    }

}
